<?php
/** Description of gpa_demo
 *  @package
 *  @version 0.1
 *  @filesource image-view.php
 *  @author Meta Sanjaya
 *  @date 03 Feb 10 4:32:00
 */

    $imageId = intval($_GET['iid']);
    $viewed = intval($db->query("SELECT viewed FROM #_gallery_images WHERE image_id=%u", $imageId)->rows[0]['viewed'])+1;
    if(!isset($_GET['notcount'])) {
        $db->query("UPDATE #_gallery_images SET viewed=%u WHERE image_id=%u", $viewed, $imageId);
    }
    $img = $db->query("SELECT file FROM #_gallery_images WHERE image_id=%u", $imageId)->rows[0]['file'];
    $imgpath = PAGE_PATH . "images/fullscreen/" . $img;
    $info = getimagesize($imgpath);

    if($info[1] > $info[0]) {
        $nwidth = 0;
        $nheight = $CONFIG['img_view_size'];
    } else {
        $nwidth = $CONFIG['img_view_size'];
        $nheight = 0;
    }
    
    $thumb = create_thumbnail($imgpath, $nwidth, $nheight, PAGE_PATH . "images/thumbnails/");
    header('content-type: ' . $info['mime']);
    echo file_get_contents($thumb);

?>
